package com.ju.demo.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.*;

import java.util.List;


//@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {



//    拦截器
    public void addInterceptors(InterceptorRegistry registry) {
        StringBuffer sb = new StringBuffer();
        sb.append("/swagger-resources/**");
        sb.append("/swagger-ui.html**");
        super.addInterceptors(registry);
    }


//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath: /META-INF/resources/");
//        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath: /META-INF/resources/webjars/");
//        registry.addResourceHandler("/**").addResourceLocations("classpath:/statics/");
//    }
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");

    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
    registry.addResourceHandler("/**").addResourceLocations("classpath:/statics/");
}

    public StringHttpMessageConverter stringHttpMessageConverter(){ return new StringHttpMessageConverter(); }

    public void configureMessageConverters(List<HttpMessageConverter<?>> converters){
        converters.add(stringHttpMessageConverter());
    }
}
